from django.conf import settings
from rest_framework import serializers
from .models import Upload


class UploadSerializer(serializers.ModelSerializer):
    filepath = serializers.SerializerMethodField()

    def get_filepath(self, obj):
        return settings.TENCENT_CLOUD['IMAGE_URL'] + obj.filepath

    class Meta:
        model = Upload
        fields = ('id', 'filepath')
